package com.ccz.demo.design.singleton.shuangchongsuojiaoyan;

/**
 * 双重锁校验
 *
 * @ClassName Single
 * @Author caihaoyun
 * @Date 2020/7/6
 * @Version V1.0
 **/
public class Single {

    private volatile static Single singleton;  //1:volatile修饰

    private Single(){}

    public static Single getSingleton() {
        if (singleton == null) {
            synchronized (Single.class) {
                if (singleton == null) {
                    singleton = new Single();
                }
            }
        }
        return singleton;
    }

}
